﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System;
using System.Windows.Forms;
using Coronox.SkyShell;
using System.Diagnostics;

namespace SkyShellExTestForm
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                textBoxSyncFolderPath.Text = folderBrowserDialog1.SelectedPath;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                textBoxStopSyncFolderPath.Text = folderBrowserDialog1.SelectedPath;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                Sky.SyncFolder(textBoxSyncFolderPath.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                textBoxSharedFolderPath.Text = folderBrowserDialog1.SelectedPath;

        }

        private void buttonLogin_Click(object sender, EventArgs e)
        {
            WLLoginBrowserWindowTest browser = new WLLoginBrowserWindowTest();
            browser.Show();

        }

        private void buttonGetSharedLink_Click(object sender, System.EventArgs e)
        {
            //if (SkyDriveAction.RenewRefreshToken())
            //{
            //    SkyDriveDirectoryInfo folder = SkyDriveAction.GetSkyDriveFolder(textBoxSharedFolderPath.Text);

            //    string strShareUrl = SkyDriveAction.GetReadonlySharedLink(folder.ID);

            //    string address = "";
            //    string subject = "Somebody did share a folder with you".ToMailto();
            //    string cc = " ";
            //    string bcc = " ";
            //    string body = String.Format("Sie sind zur Ansicht des Ordners {0} <{1}> eingeladen", folder.Name, strShareUrl).ToMailto();
            //    string mail = String.Format("mailto:{0}?subject={1}&cc={2}&bcc={3}&body={4}", address, subject, cc, bcc, body);
            //    Process.Start(mail);
            //}
            //else
            //{
            //    WLLoginBrowserWindowTest browser = new WLLoginBrowserWindowTest();
            //    browser.Show();
            //}



        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                Sky.StopSyncFolder(textBoxStopSyncFolderPath.Text, StopSyncOption.Detach);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
